<?
	session_start();//abrir la session del usuario	
	include "../../resources/seguridad/seguridad.php";
	$raizPagina = "../";
	
	require_once "../../resources/bd/db.php";
	include "../../clases/personal.class.php";
	//include "../../clases/nivel_educativo.class.php";
	//include "../../clases/profesion.class.php";	
	//include "../../clases/idioma.class.php";	
	//include "../../clases/ubicacion.class.php";
	//include "../../clases/cargo.class.php";	
	//include "../../clases/oferta.class.php";	
	//include "../../clases/clasificacion.class.php";	

	$p = new Personal;
	//$ne = new NivelEducativo;
	//$pro = new Profesion;	
	//$idioma = new Idioma;
	//$ubic = new Ubicacion;
	//$car = new Cargo;
	//$of = new Oferta;
	//$cla = new Clasificacion;

//Setting de cantidad de registros
if( $_REQUEST["numRegistros"] != "")
{
	$registros = $_REQUEST["numRegistros"];
}
else
{
	$registros = 10;				
}
//parametros de busqueda	
$nombre = $_REQUEST['nombre'];
$cedula = $_REQUEST['cedula'];//código de la persona dentro de la aplicación
$id_nivel_educativo = $_REQUEST['id_nivel_educativo'];// el nivel educativo seleccionado
$sexo = $_REQUEST['sexo'];// el sexo seleccionado
$id_profesionARR = $_REQUEST['id_profesion'];
$id_oferta = $_REQUEST['id_oferta'];


$id_idioma = $_REQUEST['id_idioma'];
$id_cargo = $_REQUEST['id_cargo'];
$id_ubicacion = $_REQUEST['id_ubicacion'];
$id_clasificacion = $_REQUEST['id_clasificacion'];

$arreglo = $p->listar();
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SCA</title>
<style type="text/css">
<!--
.boton{
        font-size:10px;
        font-family:Verdana,Helvetica;
        font-weight:bold;
        color:white;
        background:url(../images/Button.JPG);
        border:0px;
        width:80px;
        height:27px;
 }
.style1 {color: #FFFFFF}
.style4 {
	color: #7BAA0F;
	font-weight: bold;
}
.style5 {
	font-family: Garamond;
	font-weight: bold;
}
.contenido {
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-weight:normal;
	font-size:9px;
}
-->
</style>
<script type="text/javascript" src="../menu/jquery-1.2.2.pack.js"></script>
<script type="text/javascript" src="../menu/ddaccordion.js">
</script>
<script type="text/javascript">


ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='../menu/plus.gif' class='statusicon' />", "<img src='../menu/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


</script>
</head>



<body topmargin="0" bgcolor="#FFFFFF">
<form name="myForm" action="persona.php" method="post">
<table width="800" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td height="84" colspan="2"  background="../images/img01.png">&nbsp;</td>
  </tr>
  <tr>
  	<td align="center">
		<table cellpadding="0" cellspacing="0">
		<tr>
    		<td align="center" valign="middle"><img src="../images/Administracion.png" width="112" height="117" />
			<br><span class="style4"><? echo $_SESSION["usuario"]; ?></span></td>
		</tr>
		<tr>
			<td align="left" valign="top"><? include "../menu/menuPrincipal.php"?></td>  
		</tr>
		</table>
	</td>
	<td><!--Panel de Busqueda-->
		<table width="88%" align="center">
			<tr>
				<td width="13%" class="etiqueta style5"><span class="style7">Nombre</span></td>
				<td width="37%" class="contenido"><input class="contenido" type="text" name="nombre"value="<? echo $nombre; ?>"  /></td>
				<td width="13%" class="etiqueta style5"><span class="style7">C&oacute;digo</span></td>
				<td width="37%" class="contenido"><input class="contenido" type="text" name="cedula"value="<? echo $cedula; ?>" /></td>
			</tr>					
		</table><!--Fin panel de Busqueda-->
		<br>
		<table width="96%" border="2" align="center" bordercolor="#000033" bgcolor="#FFFFFF">
			<tr>			
				<td colspan="11" align="right" ><input type="button"  class="boton" name="desactivar" value="Eliminar" onclick="javascipt:activar('_desactivar.php','Usted esta seguro de eliminar las personas seleccionadas')"></td>							
			</tr>
			<tr>
				<td align="center" bgcolor="#000000" class="style1 tituloTabla"><input name="checkall" type="checkbox" id="checkall" value="checkall" onClick="checkAll();" /></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Código</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Nombre</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Cedula</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Sexo</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Nivel de Educación</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Fecha Nacimiento</strong></td>				
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Profesión</strong></td>	
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Email</strong></td>
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Curriculum</strong></td>				
				<td align="center" bgcolor="#000000" class="tituloTabla style1"><strong>Idioma</strong></td>
			</tr>
			<?
				$max = count($arreglo["id_personal"]);
				
				$pagina = $_GET["pagina"];
				if (!$pagina) 
				{
					$inicio = 0;
					$pagina = 1;
				}
				else 
				{
					$inicio = ($pagina - 1) * $registros;
				} 
				$total_registros = count($arreglo["id_personal"]);
				$total_paginas = ceil($total_registros / $registros);
				for($i=$inicio; $i<($inicio+$registros); ++$i) 
			   { 
				 $id = $arreglo["id_personal"][$i];
 			         //$htmlIdioma = $idioma->idiomaPorPersona($id);
				 //$ne->buscar($arreglo["id_nivel_educativo"][$i]);
				 //$pro->buscar($arreglo["id_profesion"][$i]);
				 printf("<tr ><td align='center'><input type='checkbox' name='".$id."' id='".$id."' value='".$id."' ></td>");		   	 				   	
				 printf("<td class='contenido' align='left'>".$arreglo["id_personal"][$i]."&nbsp;</td>");
				 //printf("<td class='contenido' align='left'><a href='modPersona.php?id_persona=".$id."' >".$arreglo["nombre_personal"][$i]."</a>&nbsp;</td>");
				 printf("<td class='contenido' align='left'><a href='javascript:goToEdit(".$id.")' >".$arreglo["nombre_personal"][$i]."</a>&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$arreglo["cedula_personal"][$i]."&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$arreglo["sexo_personal"][$i]."&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$ne->nombre_nivel_educativo."&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$arreglo["fecha_nacimiento_personal"][$i]."&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$pro->nombre_profesion."&nbsp;</td>");
				 printf("<td class='contenido' align='left'>".$arreglo["email_personal"][$i]."&nbsp;</td>");
				 if($arreglo["curriculum_personal"][$i] != '')
				 {
				 	printf("<td class='contenido' align='left'><a href='"."../../".$arreglo["curriculum_personal"][$i]."' target='_blank' ><img src='../../resources/img/curriculum.gif' border='0' /><a/>&nbsp;</td>");
				 }
				 else
				 {
				 	printf("<td class='contenido' align='left'>&nbsp;---&nbsp;</td>");

				 }
				 printf("<td class='contenido' align='left'>".$htmlIdioma."&nbsp;</td>");
				 printf("</tr>");		
				 $htmlIdioma = "";			
			   }
			   ?>
			 <tr>		
                <td colspan='11' align="center" bgcolor="#000000" class="tituloTabla style1">
                	<table>
                    	<tr>
                        	<td align="center" bgcolor="#000000" class="tituloTabla style1">
                            <?php
							if(($pagina - 1) > 0) {
								echo "<a href='javascript:goTo(".($pagina-1).")'>< Anterior</a> ";
							}
                            ?>
                            </td>
                            <td align="center" bgcolor="#000000" class="tituloTabla style1">
                            <?php
                            for ($i=1; $i<=$total_paginas; $i++){
							if ($pagina == $i) {
								echo "<b>".$pagina."</b> ";
							} else {
								echo "<a href='javascript:goTo(".$i.")'>$i</a> ";
							} }
							?>
                            </td>
                            <td align="center" bgcolor="#000000" class="tituloTabla style1">
                            <?php
							if(($pagina + 1)<=$total_paginas) {
								echo " <a href='javascript:goTo(".($pagina+1).")'>Siguiente ></a>";
							} 
                            ?>
                            </td>
                        </tr>
						<tr>
							<td colspan="3"  align="center" bgcolor="#000000" class="tituloTabla style1">
							<?php
								echo "Total Registros: ".$max; 
							?>
							</td>
						</tr>
                    </table>
                </td>
			</tr>
		</table>		
	</td>
  </tr>
  <tr>
    <td height="84" colspan="2" background="../images/img09.png" >&nbsp;</td></td>
  </tr>   
</table>
<input type="hidden" name="codigos" />
</form>
<script language="javascript">

function goTo(pag)
{
	document.myForm.action = "persona.php?pagina="+pag;
	document.myForm.submit();
}
function goToEdit(idP)
{
	document.myForm.action = "modPersona.php?id_persona="+idP;
	document.myForm.submit();
}
function checkAll() {

	var nodoCheck = document.getElementsByTagName("input");

	var varCheck = document.getElementById("checkall").checked;

	for (i=0; i<nodoCheck.length; i++){

		if (nodoCheck[i].type == "checkbox" && nodoCheck[i].name != "docentes" && nodoCheck[i].disabled == false) {

			nodoCheck[i].checked = varCheck;

		}

	}

}


function activar(pag,msj)
{

	var nodoCheck = document.getElementsByTagName("input");

	var cont = 0;

	if(nodoCheck.length>0)

	{

		for (i=0; i<nodoCheck.length; i++)

		{

			if ((nodoCheck[i].type == "checkbox")&&(nodoCheck[i].disabled == false))

			{				

				if (nodoCheck[i].checked)

				{

					cont++;

					if (i == 0)

					{

						document.myForm.codigos.value = nodoCheck[i].value;

					}

					else

					{

						document.myForm.codigos.value = document.myForm.codigos.value + "," + nodoCheck[i].value;

					}

				}

			}

		}

	}

	if (cont != 0)

	{

		if (confirm(msj))

		{

			document.myForm.action = pag;

			document.myForm.submit();

		}

	}

	else

	{

		alert('Seleccione una Persona');

	}

}

</script>

</body>

</html>